import 'package:flutter/material.dart';
import 'package:qunaimedical/components/custom_avatar.dart';
import 'package:qunaimedical/models/consultation.dart';
import 'package:qunaimedical/pages/timely_consultation_detail_page.dart';

class ItemTimelyConsultation extends StatelessWidget {
  final Consultation item;

  const ItemTimelyConsultation({Key key, this.item}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return InkWell(
      onTap: () {
        Navigator.push(
            context,
            MaterialPageRoute(
                builder: (c) => TimelyConsultationDetailPage(item)));
      },
      child: Container(
        color: Colors.white,
        padding: EdgeInsets.all(16),
        child: Row(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            CustomAvatar(
              avatarUrl: item.avatar,
              margin: EdgeInsets.only(bottom: 8, right: 16),
            ),
            Expanded(
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.stretch,
                children: [
                  Row(
                    children: [
                      Container(
                        width: 80,
                        child: Text(
                          item.name,
                          style: TextStyle(
                              fontSize: 16, fontWeight: FontWeight.bold),
                        ),
                      ),
                      Text('${item.sectionTypeName}'),
                    ],
                  ),
                  SizedBox(height: 8),
                  Text(
                    '主题：${item.title ?? ''}',
                    maxLines: 1,
                    overflow: TextOverflow.ellipsis,
                  ),
                  Text(
                    '内容：${item.content ?? ''}',
                    maxLines: 1,
                    overflow: TextOverflow.ellipsis,
                  ),
                  SizedBox(height: 10),
                  Text(
                    item.createDate ?? '',
                    style: Theme.of(context).textTheme.caption,
                  ),
                ],
              ),
            )
          ],
        ),
      ),
    );
  }
}
